from django.db import models

# Create your models here.


class Device(models.Model):
    id = models.AutoField(primary_key=True)
    sn = models.IntegerField(max_length=10)



class ServiceGroup(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=20,unique=True)
    desc = models.CharField(max_length=20,blank=True,null=True)
    def __unicode__(self):
        return self.name
# class Env(models.Model):
#     id = models.AutoField(primary_key=True)
#     name = models.CharField(max_length=10,unique=True)
#     desc = models.CharField(max_length=10,blank=True,null=True)

class Service(models.Model):
    id = models.AutoField(primary_key=True)
    group = models.ForeignKey(ServiceGroup)
    # env = models.ForeignKey(Env)
    name = models.CharField(max_length=20)
    desc = models.CharField(max_length=50,blank=True,null=True)


    def __unicode__(self):
        return self.name

    class Meta:
        permissions = (
            ("abview_admin", "abview Admin 权限"),
        )


class Abhost(models.Model):
    id = models.AutoField(primary_key=True)
    # env = models.CharField(max_length=10,choices=(('debug',"DEBUG"),('dev','DEV'),('test','TEST'),('qa','QA'),('demo','DEMO'),('prod','PROD')))
    env = models.CharField(max_length=10,unique=True)
    host = models.CharField(max_length=50)
    desc = models.CharField(max_length=100,null=True,blank=True)



